<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        var nums = "1234";
  var num0 = nums.substring(0, 1);
  var num1 = nums.substring(1, 2);
  var num2 = nums.substring(2, 3);
  var num3 = nums.substring(3);

  document.write(change(num0) + "千" + change(num1) + "百" + change(num2) + "十" + change(num3)+"元");

  function  change(num) {
    var  arrs= ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"];
    return arrs[num];
  }
  </script>

</body>

</html>